//
//  MyMembershipCardTableViewCell.m
//  BaseFrame
//
//  Created by 吕金状 on 2017/8/16.
//  Copyright © 2017年 com.mxh. All rights reserved.
//

#import "MyMembershipCardTableViewCell.h"

@interface MyMembershipCardTableViewCell()

@property (strong, nonatomic)  UIImageView *imgView;
@property (strong, nonatomic)  UILabel *infoLabel;
Strong UIView *lineView;
Strong UIImageView *rightImageView;

@end

@implementation MyMembershipCardTableViewCell

- (id)initWithCellIdentifier:(NSString *)cellID{
    self = [super initWithCellIdentifier:cellID];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        _imgView = [UIImageView new];
        _imgView.contentMode = UIViewContentModeScaleAspectFit;
        [self.contentView addSubview:_imgView];
        
        _rightImageView = [UIImageView new];
        _rightImageView.contentMode = UIViewContentModeScaleAspectFit;
        _rightImageView.image = [UIImage imageNamed:@"right_image"];
        [self.contentView addSubview:_rightImageView];
        
        _infoLabel  = [[UILabel alloc]init];
        _infoLabel.font = DEF_FontSize_14;
        _infoLabel.textColor = getColor(textColor);
        [self.contentView addSubview:_infoLabel];
        
        _lineView = [[UIView alloc]init];
        _lineView.backgroundColor = getColor(dividerColor);
        [self.contentView addSubview:_lineView];

        [self layoutFrame];
    }
    return self;
}

- (void)layoutFrame{
    __weak __typeof(self)weakSelf = self;
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10 / WIDTH_5S_SCALE);
        make.bottom.mas_equalTo(0);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH - 20 / WIDTH_5S_SCALE, 0.5));
    }];
    
    [self.rightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15 / WIDTH_5S_SCALE);
        make.top.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        make.width.mas_equalTo(7 / WIDTH_5S_SCALE);
    }];
    
    [self.imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15 / WIDTH_5S_SCALE);
        make.top.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        make.width.mas_equalTo(15 / WIDTH_5S_SCALE);
    }];
    
    [self.infoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.imgView.mas_right).offset(5 / WIDTH_5S_SCALE);
        make.top.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
    }];

}

- (void)setModel:(NSDictionary *)model{
    _model = model;
    self.rightImageView.hidden = YES;
    self.lineView.hidden = NO;
    if (self.indexPath.section == 0) {
        if (self.indexPath.row == 2) {
            self.lineView.hidden = YES;
        }
    }
    
    if (self.indexPath.section != 0) {
        self.rightImageView.hidden = NO;
    }
    _imgView.image = [UIImage imageNamed:model[@"image"]];
    if (model[@"content"]) {
        _infoLabel.text = [NSString stringWithFormat:@"%@%@",model[@"title"],model[@"content"]];
    }else{
        _infoLabel.text = model[@"title"];
    }
}


@end
